package com.sayp.netdisk.controller;

import com.sayp.netdisk.pojo.User;
import com.sayp.netdisk.service.DeleteService;
import com.sayp.netdisk.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/file")
public class DeleteController {
    @Autowired
    private DeleteService deleteService;
    @Autowired
    private UserController userController;

    /**
     * 删除文件
     * @param fids
     * @return
     */
    @DeleteMapping("del")
    public boolean delFile(int[] fids, HttpSession session){
        User user = userController.getUserInfo(session);
        if(user==null)return false;
        return deleteService.delFile(fids,user.getUid());
    }
}
